﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AdminRole.aspx.cs" Inherits="Admin_AdminRole"  %>

<%@ Register Src="adminfoot.ascx" TagName="adminfoot" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <link rel="stylesheet" href="imgs/admin.css" type="text/css" media="all" />
    <script type="text/javascript" src="../DotNet_net/js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="imgs/GetAjax.js"></script>
    <script type="text/javascript" src="../DotNet_net/js/common.js"></script>
</head>
<body onload="$('#loading').hide()">

  <form id="form1" runat="server">
    <div class="container" id="cpcontainer">
<div id="loading" style="display:block">   
    <div class="loading-indicator">   
        页面正在加载中...   
    </div>   
</div> 
    <ul id="makeHtmlTab">
<li class="hover"><a href="javascript:void(0)" onclick="">角色信息</a>
    </li>
</ul>
    <table class="tb" id="TABLE1" onclick="">
        <tr>
			<td align="left" style="height: 17px; width: 100px;">
                角色ID</td>
			<td  style="height: 17px; width: 230px;">
                角色名称(roleName)</td>
			<td  style="height: 17px; width: 230px;">
                角色描述(Description)</td>
            <td style="height: 17px; width: 700px;">
                角色拥有的权限(powerId)</td>
			<td  style="height: 17px; width: 230px;">&nbsp;操作（编辑角色，删除角色）</td>		
        </tr>
        
        <tr >
        <asp:Repeater ID="Repeater1" runat="server">     
      <ItemTemplate>      
<tr bgcolor="#f5fafe" >
	<td ><%#Eval("roleId")%></td>
	<td ><%#Eval("roleName") %></td>
	<td><%#Eval("Description") %></td>
	<td><a href="#" title='<%#Eval("roleId")%>' onclick="GivePower(this,this.title)"><%#getPowerBuyRoleId(Convert.ToInt32(Eval("roleId").ToString()))%></a> </td>
	<td>
	  <input id="Button5" type="button" value="编辑" class='btn' title='<%#Eval("roleId") %>' onclick="$('#loading').show();ajax_get(convertURL('AdminRole.aspx?action=edit&roleId='+this.title),'',function(msg){$('#cpcontainer').empty().append(msg);$('#loading').hide();});"/>
	   <input id="btnDel" type="button" value="删除" class='btn' title='<%#Eval("roleId") %>' onclick="if(confirm('确定要删除吗')){$('#loading').show();ajax_get(convertURL('AdminRole.aspx?action=del&roleId='+this.title),'',function(msg){$('#cpcontainer').empty().append(msg);$('#loading').hide();location.href=location.href;});}else{return false}"/>	
		<input id="btn" type="button" value="解除关联" class="btn" title='<%#Eval("roleId") %>' onclick="if(confirm('确定要解除关联吗')){$('#loading').show();ajax_get(convertURL('AdminRole.aspx?action=delTb&roleId='+this.title),'',function(msg){$('#cpcontainer').empty().append(msg);$('#loading').hide();location.href=location.href;});}else{return false}" />      
	</td>
  </tr>   
      </ItemTemplate>  
      </asp:Repeater>              
        </tr>
        </table>
        <br />
<ul id="makeHtmlTab2"><li class="hover"><a href="javascript:void(0)" >添加/编辑角色</a></li></ul>
    <table class="tb" id="addRole">
    <tr class="thead"><th colspan="8">
        添加角色</th></tr>	
        <tr align="center">
            <td style="width: 189px" >
                角色名称：
            </td>
            <td style="width: 159px">
                <input id="txt_roleName" style="width: 100px" type="text" name="txt_roleName" value="" runat="server" /><span style="color: #ff0000">＊</span></td>
            <td align="center" style="width: 100px">
                角色描述:</td>
            <td align="left" colspan="2" style="width: 1175px">
                <input id="txt_Description" type="text" name="txt_Description" value="" runat="server"/><span style="color: #ff0000">＊</span></td>
    </tr>
        <tr align="center">
            <td align="center" colspan="6">                
                <input id="InsertRole" class="btn" onclick="addPower('','ck_name')" type="button" value="确认保存" />
               </td>
        </tr>
</table>
<input id="roleId_hid" runat="server" type="hidden" value="0" />
</div>      
      <uc1:adminfoot ID="Adminfoot1" runat="server" />
</form>
<script type="text/javascript">
    function addPower(url,name)
    {
        $("#loading").show();
        var ids=getIDList(name);
        var Param='';
        if($("#txt_roleName").attr("value")!="")
        {        
           
            if($("#roleId_hid").attr("value")!="0")
             {
                url=convertURL(url+"AdminRole.aspx?action=update&id="+ids+"&roleId="+$("#roleId_hid").attr("value")); 
                Param+="&roleName="+$("#txt_roleName").attr("value")+"&Des="+$("#txt_Description").attr("value");            
                ajax_post(url,Param,function(msg){   
                 $("#cpcontainer").empty().append(msg);  
                 $("#loading").hide();              
                });  
                location.href="adminRole.aspx";             
             }
             else
             {
                 url=convertURL(url+"AdminRole.aspx?action=add&id="+ids+"&roleId="+$("#roleId_hid").attr("value")); 
                 Param+="&roleName="+$("#txt_roleName").attr("value")+"&Des="+$("#txt_Description").attr("value");  
                 ajax_post(url,Param,function(msg){
                    $("#cpcontainer").empty().append(msg);
                    $("#loading").hide();  
                });                
             }
        } 
        else
        {
            alert("角色名不能为空！");
            $("#loading").hide();  
        }
    } 
</script>
<script type="text/javascript">
function GivePower(tg,title)
{
   var  el=$(tg).prev()[0];
   _1=el;openWindow2(20,420,400,0);
	var msgDiv=document.getElementById("msg");
	var _t = tg.offsetTop;
    var _l = tg.offsetLeft;
    while (tg = tg.offsetParent){_t+=tg.offsetTop; _l+=tg.offsetLeft;}
    msgDiv.style.cssText+="border:1px solid #55BBFF;background: #C1E7FF;padding:1px 0px 1px 1px;height: auto;"
	msgDiv.style.top = (_t-1)+"px";
    msgDiv.style.left = (_l-1)+"px";
	msgDiv.innerHTML='<button type="button" class="btn" style="margin:0 6px 0 0;height:23px;float:right;padding:0;" onclick="closeWin()">关闭</button><iframe src="FileDownLoad/selectRole.aspx?roleId='+title+'" scrolling="no" topmargin="0"  height:auto;overflow:auto;  marginwidth="0" marginheight="0" frameborder="0" align="center"  onload="this.height=this.contentWindow.document.documentElement.scrollHeight"></iframe>';
}
</script>
</body>
</html>
